package models;
import java.util.List;
import javax.persistence.*;
import models.RegisteredUser;
import 	play.db.jpa.*;

@Entity
public class Request extends Model{
	
	public long requesterID;
	public long replierID;
	public long entityID;
	public String reqType;
	public boolean isConfirmed;
	public boolean isRejected;
	public String path;
	
	public Request(long requester, long t,long replier, String reqType, String path) {
		this.requesterID = requester;
		this.entityID = t;
		this.replierID = replier;
		this.reqType = reqType;
		this.isConfirmed = false;
		this.isRejected = false;
		this.path = path;
//		this.save();
	}
	
	public String toString() {
		RegisteredUser user = RegisteredUser.findById(this.requesterID);
		String s ="";
		if (this.reqType.equals("request to Contribute")) {
			Tutorial tut = Tutorial.findById(this.entityID);
			s = "" + user.name + " has send you a "+ reqType +" to "+ tut.Title;
		}
		else if (this.reqType.equals("request to Review")) {
			Exercise x = Exercise.findById(this.entityID);
			s = "" + user.name + " has send you a "+ reqType +" to "+ x.getExerciseName();
		}
		return s;
	}
	
	public String getPath() {
		return path;
	}
	public  void setConfirmed() {
		this.isConfirmed = true;
	}
	public  void setRejected() {
		this.isRejected = true;
	}
	
}
